<!DOCTYPE html>
<html lang="en">
	<head>

		<meta charset="UTF-8" />
		<script>
			var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
				CSS.supports('top: constant(a)'))
			document.write(
				'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
				(coverSupport ? ', viewport-fit=cover' : '') + '" />')
		</script>
		<title></title>
		<!--preload-links-->
		<!--app-context-->
	</head>
	<body>
		<div id="app"><!--app-html--></div>
		
			<!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
			<script>
				var vConsole = new window.VConsole();
			</script> -->
			
		<script src="./rawsdk3/zjsdk3.js"></script>
		<script src="./rawsdk3/drawBoard.js"></script>
		<script type="module" src="/main.js"></script>

		<!-- <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script> -->
		
		<script>
			// 示例开始，以下几行代码即可成功入会专属云平台:
			var inMeeting = false
			window.onload =()=> {
				// getDemoConfig()
				window.zjsdk3 = new ZjSdk3();
				window.videoLsit = []
				window.audioinput = []
				window.audiooutput = []
				window.Invalidpin=0
				
				

				zjsdk3.on_dev_test_device_failed=(is_camera,device_id,reason)=>{
					
				}
				// 重写回调
				zjsdk3.on_dev_call_failed = (reason) => {
					unihide()
					if (reason == 'Error: Meeting is not found') {
						uniToast({
							title: "会议号不存在",
							icon: "none"
						})
					} else if (reason == 'Error: Invalid PIN') {
						Invalidpin++
						uniemit('joinpwd')
						if(Invalidpin>1){
							uniToast({
								title: "输入密码错误",
								icon: "none"
							})
						}
					} else {
						uniToast({
							title:reason + '',
							icon:"none"
						})
					}
				
				}
				
				zjsdk3.on_dev_call_succeed = async () => {
					uniemit('callSucceed')
					
					//uni.$emit('callSucceed')
					// uni.hideLoading()
					// uni.navigateTo({
					// 	url: './video?priv_room_cuid=' + this.huiyihao + '&huiyiname=' + this.huiyiname +
					// 		'&ismic=' + (this.ismic ? '1' : '0') + '&iscam=' + (this.iscam ? '1' : '0')
					// })
				}

				

				zjsdk3.on_dev_device_removed = (device_id, kind) => {

					// this.listvideo.map((item, index) => {
					// 	if (item.device_id == device_id) {
					// 		this.listvideo.splice(index, 1)
					// 	}
					// })

					if (kind == 'videoinput') {
						videoLsit.map((item, index) => {
							if (item.device_id == device_id) {
								videoLsit.splice(index, 1)
							}
						})
					} else if (kind == 'audioinput') {
						audioinput.map((item, index) => {
							if (item.device_id == device_id) {
								audioinput.splice(index, 1)
							}
						})
					} else {
						audiooutput.map((item, index) => {
							if (item.device_id == device_id) {
								audiooutput.splice(index, 1)
							}
						})
					}
					
					setTimeout(()=>{
						if(uniemit){
							uniemit('updateMsg')
						}
					},2000)
				}

				zjsdk3.on_dev_device_added = (device_id, label, kind, is_default) => {


					if (kind == 'videoinput') {
						let vidoObj = {}
						vidoObj = {
							is_default:is_default,
							value:device_id,
							device_id: device_id, //设备id
							label: label //摄像头
						}
						videoLsit.push(vidoObj)

					} else if (kind == 'audioinput') {
						let vidoObj = {}
						vidoObj = {
							is_default:is_default,
							value:device_id,
							device_id: device_id, //设备id
							label: label //麦克风
						}
						
						audioinput.push(vidoObj)
						
					} else {
						let vidoObj = {}
						vidoObj = {
							is_default:is_default,
							value:device_id,
							device_id: device_id, //设备id
							label: label //扬声器
						}
						audiooutput.push(vidoObj)

					}
						if(uniemit){
							uniemit('updateMsg')
						}
				}
					
					
					
					

				// setTimeout( async ()=>{
				// 	let Videores = await zjsdk3.preview_dev_open_camera(this.videoLsit[0].device_id)

				// 	let localvideo = document.querySelector('#previewVideo') //存放预览摄像头视屏流的盒子
				// 	if (localvideo) {
				// 	  localvideo.srcObject = Videores
				// 	  localvideo.play()
				// 	}
				// },1500)

			}

			// 参会人信息更新
			// function demo_on_dev_participant_update(pp, changed_keys) {
			//   uuidList.push(pp.uuid)
			//   sessionStorage.setItem('uuid', uuidList)
			// }

			// 获取当前的本地设备
			// function demo_on_dev_device_added(device_id, label, kind, is_default) {
			// 	//获取摄像头列表
			// 	if (kind == 'videoinput') {
			// 		vidoObj = {
			// 			device_id: device_id, //设备id
			// 			label: label //设备名称
			// 		}
			// 		videoLsit.push(vidoObj) //存放摄像头设备的list
			// 		//获取摄像头设备列表
			// 		let select = document.getElementById('videoDevices')
			// 		//获取切换视频源的设备列表
			// 		let selects = document.getElementById('overVideo')
			// 		select.options.length = 0
			// 		selects.options.length = 0
			// 		videoLsit.forEach((item) => {
			// 			select.options.add(new Option(item.label, item.device_id));
			// 			selects.options.add(new Option(item.label, item.device_id));
			// 		})
			// 	} else if (kind == 'audioinput') {
			// 		audioObj = {
			// 			device_id: device_id, //设备id
			// 			label: label //设备名称
			// 		}
			// 		audioList.push(audioObj) //存放麦克风设备的lsit
			// 		// 获取麦克风设备列表
			// 		let select = document.getElementById('audioDevices')
			// 		//获取切换音频源的设备列表
			// 		let selects = document.getElementById('overAudio')
			// 		select.options.length = 0
			// 		selects.options.length = 0
			// 		audioList.forEach((item) => {
			// 			select.options.add(new Option(item.label, item.device_id));
			// 			selects.options.add(new Option(item.label, item.device_id));
			// 		})
			// 	}
			// }

			// 呼叫成功时的回调
			// function demo_on_dev_call_succeed() {
			//   // 回显本地视频
			//   zjsdk3.local_dev_show_myvideo(['local_video'], true)
			//   // 显示远端视频
			//   zjsdk3.show_video_by_orders(['farend_video', 'farend_video2', 'farend_video3', 'farend_video4', 'farend_video5'])
			//   // 入会成功后打开当前默认的摄像头和麦克风
			//   let equipmentVideo = document.getElementById("videoDevices").value
			//   let equipmentAudio = document.getElementById("audioDevices").value
			//   zjsdk3.local_dev_switch_cam(equipmentVideo)
			//   zjsdk3.local_dev_switch_mic(equipmentAudio)
			// }


			// 预览本地摄像头
			// window.preview = async function() {
			// 	let videoValue = document.getElementById("videoDevices").value //当前摄像头设备变化的id
			// 	let Videores = await zjsdk3.preview_dev_open_camera(videoValue)
			// 	let localvideo = document.querySelector('#previewVideo') //存放预览摄像头视屏流的盒子
			// 	if (localvideo) {
			// 		localvideo.srcObject = Videores
			// 		localvideo.play()
			// 	}
			// }

			// 呼入会议
			window.start_call = async function() {
				if (!inMeeting) {
					inMeeting = true
					// 将用户输入的服务器地址、会议号、入会密码、昵称存入配置文件中

					await zjsdk3.make_call_now('api.51vmr.cn', '443', '8003333', '1111', 'hhh', '')
				}
			};

			// 离开会议室
			window.disconnect = async function() {
				await zjsdk3.disconnect_now()
				window.inMeeting = false
				zjsdk3.preview_dev_finished()
				zjsdk3.local_dev_mute_cam(true)
				zjsdk3.local_dev_mute_mic(true)
			};

			//切换本地视频源
			window.changeDevice = function() {
				var deviceId = document.getElementById("overVideo").value
				zjsdk3.local_dev_switch_cam(deviceId)
			}
			//切换本地音频源
			window.changeMic = function() {
				var deviceId = document.getElementById("overAudio").value
				zjsdk3.local_dev_switch_mic(deviceId)
			}

			//打开本地摄像头
			window.Open_muteVideo = function() {
				var deviceId = document.getElementById("overVideo").value
				zjsdk3.local_dev_switch_cam(deviceId)
			}
			// 关闭本地摄像头
			window.Close_muteVideo = function() {
				zjsdk3.local_dev_mute_cam(true)
			}

			// 打开本地麦克风
			window.Open_muteAudio = function() {
				var deviceId = document.getElementById("overAudio").value
				zjsdk3.local_dev_switch_mic(deviceId)
			}
			//关闭本地麦克风
			window.Close_muteAudio = function() {
				zjsdk3.local_dev_mute_mic(true)
			}

			// 指定观看视频流
			window.force_get_streams = function() {
				if (sessionStorage.getItem('uuid')) {
					let uuid_list = sessionStorage.getItem('uuid').split(',')
					let layout = '1:' + (uuid_list.length - 1)
					zjsdk3.buffet_set_override_clayout(uuid_list, true, layout)
				}
			}
			// 使用平台推荐的视频流
			window.cancel_force_get_streams = async function() {
				if (sessionStorage.getItem('uuid')) {
					let uuid_list = sessionStorage.getItem('uuid').split(',')
					let layout = '1:' + (uuid_list.length)
					zjsdk3.buffet_set_clayout(layout)
				}
			}
		</script>
	
		
		<script  id="pdf"></script>
		<script id="Pdfwork"></script>
		<script language="javascript">
		    pdf.src = "./rawsdk3/pdf.js"
		    Pdfwork.src = "./rawsdk3/pdf.worker.js"
			
		</script>
		
	</body>
</html>